////////////////////////////////////////////////////////////////////////////////
//
//  http://www.17nce.com
//  Copyright 2011-2012 
//  All Rights Reserved.
//
//  gtshao@sina.cn  2010-12-25
//
////////////////////////////////////////////////////////////////////////////////
package com.nce.model{
	import flash.net.NetConnection;
	import flash.net.ObjectEncoding;
	import flash.net.Responder;
	
	import org.puremvc.as3.interfaces.IProxy;
	import org.puremvc.as3.patterns.proxy.Proxy;

	/**
	 * 
	 */
	public class CommonProxy extends Proxy implements IProxy{
		
		private var gateway:String;
		public function CommonProxy(gw:String,proxyName:String=null, data:Object=null)
		{
			gateway = gw;
			super(proxyName, data);
		}
		
		protected function onFault(fault:Object):void{
			for (var i:String in fault) {
				trace("Error: " + i + ": " + fault[i]);
			}
			
		}
		
		protected function call(serverName:String,responder:Responder,...parms):void{
			var cn:NetConnection = new NetConnection();
			cn.objectEncoding = ObjectEncoding.AMF3;
			cn.connect(gateway);
			if(parms.length < 2){
				cn.call(serverName,responder,parms[0]);
			}else if(parms.length ==2){
				cn.call(serverName,responder,parms[0],parms[1]);
			}else if(parms.length == 3){
				cn.call(serverName,responder,parms[0],parms[1],parms[2]);
			}else if(parms.length == 4){
				cn.call(serverName,responder,parms[0],parms[1],parms[2],parms[3]);
			}else if(parms.length == 4){
				cn.call(serverName,responder,parms[0],parms[1],parms[2],parms[3],parms[4]);
			}else if(parms.length == 5){
				cn.call(serverName,responder,parms[0],parms[1],parms[2],parms[3],parms[4],parms[5]);
			}else{
				trace("太多参数了,有没有搞错呀!换换设计吧!");
			}
		}
	}
	
	
}